package com.java.array;

import java.util.Arrays;
import java.util.List;

public class Client {

	public void hashCodeTest(){
		int[] intAr = {0,1,2,3,4,5,6};
		int[] intAr2 = {0,1,2,3,4,5,6};
		System.out.println(Arrays.hashCode(intAr));
		System.out.println(Arrays.hashCode(intAr2));
		System.out.println(Arrays.hashCode(intAr)==Arrays.hashCode(intAr2));//true
	}
	public void fill(){
		int[] intAr = {0,1,2,3,4,5,6};
		Arrays.fill(intAr,9);
		System.out.println(Arrays.toString(intAr));
		//[9, 9, 9, 9, 9, 9, 9]
		Arrays.fill(intAr,6,19,8);//ArrayIndexOutOfBoundsException
		System.out.println(Arrays.toString(intAr));
	}
	public void equals(){
		int[] intAr = {0,1,2,3,4,5,6};
		int[] intAr2 = {0,1,2,3,4,5,6};
		System.out.println(intAr.equals(intAr2));//false
		System.out.println(Arrays.equals(intAr, intAr2));//true
		int[] intAr3 = null;
		int[] intAr4 = null;
		System.out.println(Arrays.equals(intAr3, intAr4));//true
	}
	public void copyOfRange(){
		int[] intAr = {0,1,2,3,4,5,6};
		intAr = Arrays.copyOfRange(intAr, 5, 9);
		System.out.println(Arrays.toString(intAr));
		//[5, 6, 0, 0]
	}
	public void copyOf(){
		int[] intAr = {};
		intAr = Arrays.copyOf(intAr, 7);
		System.out.println(Arrays.toString(intAr));
		//[0,0,0,0,0,0,0]
	}

	public void binarySearch(){
		byte[] byteArray = {122,124,5,2,3,3,7,9,6};
		Arrays.sort(byteArray);
		System.out.println(Arrays.toString(byteArray));
		System.out.println(Arrays.binarySearch(byteArray, (byte)3));
	}

	public void asList(){
/*		List list = Arrays.asList();
		System.out.println(list);//[]
*/
/*		List list = Arrays.asList(null);
		System.out.println(list);
		//java.lang.NullPointerException
*/
/*		//List<Object> list = Arrays.asList(1,2);
		//list to list<Integer>
		List list = Arrays.asList(1,2);
		System.out.println(list);//[1, 2]
*/
		List<Integer> list = Arrays.asList(new Integer[]{2,3});
		System.out.println(list);//[2, 3]
	}
}
